/* This file is part of the Crimsoon project
  * Copyright (C) 2009 Eduardo Henrique <eduardohleite@gmail.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public License
  * along with this library; see the file COPYING.LIB.  If not, write to
  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
*/

#ifndef QUERYLIBRARY_H
#define QUERYLIBRARY_H

#include <QString>

const QString QUERY_GALLERY_FILE_COUNT = "SELECT count(*) FROM audio;";

const QString QUERY_GALLERY_FILE_ALL = "SELECT track AS Track, title AS Title, artist AS Artist, album AS Album, lenght AS Lenght, "
        "path AS Path FROM audio ORDER BY artist, album, track, title;";

const QString QUERY_GALLERY_FILE_ARTIST = "SELECT track AS Track, title AS Title, artist AS Artist, album AS Album,lenght AS Lenght, "
        "path AS Path FROM audio WHERE artist = :artist ORDER BY artist, album, track, title;";

const QString QUERY_GALLERY_FILE_ALBUM = "SELECT track AS Track, title AS Title, artist AS Artist, album AS Album,lenght AS Lenght, "
        "path AS Path FROM audio WHERE artist = :artist AND album = :album ORDER BY artist, album, track, title;";

const QString QUERY_GALLERY_AUDIO_ALL_ARTISTS = "SELECT DISTINCT artist FROM audio;";

const QString QUERY_GALLERY_AUDIO_ALL_ALBUMS = "SELECT DISTINCT album FROM audio WHERE artist = :artist;";

const QString QUERY_GALLERY_AUDIO_ADD = "INSERT INTO audio (path, title, album, track, artist, genre, year, lenght, bitrate, dir)"
      " VALUES (:path, :title, :album, :track, :artist, :genre, :year, :length, :bitrate, :dir);";

const QString QUERY_GALLERY_AUDIO_REMOVE = "DELETE FROM audio WHERE path = :path;";

const QString QUERY_GALLERY_DIR_ADD = "INSERT INTO dir (path) VALUES (:path);";

const QString QUERY_GALLERY_DIR_LAST = "SELECT max(code) FROM dir;";

const QString QUERY_GALLERY_DIR_EXISTS = "SELECT 1 FROM dir WHERE path = :path";

const QString QUERY_GALLERY_ALBUM_EXISTS_HAS_PICTURE =
        "SELECT (CASE WHEN picture IS NULL THEN 1 ELSE 0 END) has_picture FROM ALBUM WHERE title = :album AND artist = :artist;";

const QString QUERY_GALLERY_ALBUM_ADD = "INSERT INTO album (title, artist) VALUES (:album, :artist);";

const QString QUERY_GALLERY_ALBUM_SELECT =
        "SELECT code, title, artist, picture FROM album WHERE title = :album AND artist = :artist;";

const QString QUERY_GALLERY_ALBUM_ADD_PICTURE =
        "INSERT INTO album (title, artist, picture) VALUES (:album, :artist, :picture);";

const QString QUERY_GALLERY_DIR_REMOVE = "DELETE FROM audio WHERE dir = (SELECT code FROM dir WHERE path = :path);";

#endif // QUERYLIBRARY_H
